package com.zhj.micro.order.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.zhj.micro.order.entity.dto.OrderDTO;
import com.zhj.micro.order.service.OrderService;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("order")
public class OrderController {
    /**
     * 服务对象
     */
    @Resource
    private OrderService orderService;

    @PostMapping("/create")
    public String createOrder(@RequestBody OrderDTO orderDTO) {
        return this.orderService.createOrder(orderDTO);
    }

    @GetMapping("/pay/{orderId}")
    public boolean payOrder(@PathVariable("orderId") String orderId) throws JsonProcessingException {
        return this.orderService.payOrder(orderId);
    }

}
